package com.jz.stockidentificationclass.mapper;

import com.jz.legalpersonclass.model.LegalPersonVo;
import com.jz.planclass.model.PlanClassVo;
import com.jz.stockidentificationclass.model.StockidentificationSelectVo;
import com.jz.stockidentificationclass.model.StockidentificationUpdateVo;
import com.jz.stockidentificationclass.model.StockidentificationVo;
import com.jz.subclass.model.SubClassVo;
import org.apache.ibatis.annotations.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * Created by WISE on 2021/12/26.
 */
@Mapper
public interface StockidentificationMapper {


    List<StockidentificationVo> queryData(StockidentificationSelectVo stockidentificationSelectVo);

    int queryCount(StockidentificationSelectVo stockidentificationSelectVo);

    @Select("select * from stockidentification where code = #{code}")
    StockidentificationVo queryByCode(String code);

    @Select("select * from stockidentification where name = #{name}")
    StockidentificationVo queryByName(String name);

    @Insert("insert into stockidentification(name,code,status,remark,createTime,createName)" +
            "values(#{name},#{code},#{status},#{remark},#{createTime},#{createName})")
    void add(StockidentificationVo classVo);

    @Select("select * from stockidentification where id = #{id}")
    List<StockidentificationVo> queryById(Integer id);

    @Select("select code subCode from subclass where subName = #{subName}")
    StockidentificationVo queryBySubName(@NotBlank(message = "备件小类名称不能为空") String subName);

    @Select("select code planCode from planclass where planName = #{planName}")
    StockidentificationVo queryByPlanName(@NotBlank(message = "备件小类名称不能为空") String planName);

    @Select("select *  from legalpersonclass where legalPersonName = #{legalPersonName}")
    LegalPersonVo queryByLegalName(@NotBlank(message = "法人名称不能为空") String legalPersonName);

    @Select("select legalPersonCode legalCode,legalPersonName legalName from legalpersonclass where userId = #{userId}")
    List<StockidentificationVo> queryByUserId(Integer userId);

    @Select("select * from subclass ")
    List<SubClassVo> queryAll();

    @Select("select * from planclass ")
    List<PlanClassVo> queryAll2();

    @Update("update stockidentification set name = #{name},updateTime = #{updateTime},updateName = #{updateName},remark = #{remark},code = #{code} where id = #{id}")
    int update(StockidentificationVo classVo);

    @Update("update partclass set status = #{status},updateTime = #{updateTime},updateName = #{updateName} where id = #{id}")
    void updateStatus(StockidentificationVo classVo);

    @Delete("delete from partlegal where partCode = #{code}")
    void delete(String code);

}
